import fetch from '@/assets/config/fetch'
import {getStore} from '@/assets/config/mUtils'
 //var interfaceUrl = 'http://192.168.43.151:8082';
 // var interfaceUrl = 'http://192.168.43.160:8081';
 var interfaceUrl = 'http://192.168.43.201:8080/eHR';
 //  var interfaceUrl = 'http://hr.radiance.com.cn:8080';
if (process.env.NODE_ENV == 'development') {
  interfaceUrl = '/';
}
/*登录*/ //上线时删除
// export const login = (data) => fetch('/api/login/logon',data, 'POST','ajax',true);
export const login = (data) => fetch('/api/login/logon',data, 'POST','ajax',false,'','clock');




/*中铁建接口开始*/
/* 获取代码集名称（已改为获取所有的代码集，废弃） */
export const getCodeName = (data) => fetch('/mvc/appSelf/codeitemname/'+data.id, data, 'POST','ajax',false);
export const getorgName = (data) => fetch('/mvc/appSelf/orgname/'+data.id, data, 'POST','ajax',false);
export const getpostName = (data) => fetch('/mvc/appSelf/postname/'+data.id, data, 'POST','ajax',false);
/* 获取人员姓名 */
export const getpersonName = (data) => fetch('/mvc/appSelf/person/'+data.id, data, 'POST','ajax',false);
/*所有代码集请求*/
export const getCodeSetData = (useId,dates) => fetch('/api/operatecache/cache/0100,0120,3173,4003,3096,3090,3247,3091,3650,3512,3133,0090,0408,0400,3673,1064,3017,0145,org,post,3659,3649',dates, 'GET', 'ajax',false);


/*人员需求待办数据查询*/
export const getPersonRequireData = (data) => fetch('/mvc/appSelf/actData', data, 'POST','ajax',false);
/*人员调动和变动待办数据查询*/
export const getPersonTransferData = (data) => fetch('/mvc/appSelf/queryPersonSecondmentInfoByMap', data, 'POST','ajax',false);
/*人员辞退待办数据查询*/
export const getDismissData = (data) => fetch('/mvc/appSelf/fireactdata', data, 'POST','ajax',false);
/*人员离职待办数据查询*/
export const getPersonQuitData = (data) => fetch('/mvc/appSelf/leaveActData', data, 'POST','ajax',false);
/*人员出国境待办数据查询*/
export const getGoAbroadData = (data) => fetch('/mvc/appSelf/actAbroadData', data, 'POST','ajax',false);
/*人员入职待办数据查询*/
export const getPersonEntryData = (data) => fetch('/mvc/appSelf/entryActData', data, 'POST','ajax',false);
/*人员转正待办数据查询*/
export const getPersonRegularData = (data) => fetch('/mvc/appSelf/turnPositiveActData', data, 'POST','ajax',false);
/*人员转正节点信息接口*/
export const getRegularNode = (data) => fetch('/mvc/appSelf/getTurnPositivePoint', data, 'POST','ajax',false,'','clock');
/*人员转正保存数据*/
export const saveRegularData = (data) => fetch('/mvc/appSelf/turnPositiveSave', data, 'POST','ajax',false,'','clock');
/*审批提交接口*/
export const submitApply = (data) => fetch('/mvc/appSelf/handleTask', data, 'POST','ajax',false,'','clock');
/*待办附件接口*/
export const getAttachment = (data) => fetch('/mvc/appSelf/actAttachmentDatas', data, 'POST','ajax',false);

/* 获取机构 */
export const getOrg = (data) => fetch('/mvc/appSelf/org', data, 'POST','ajax',false);

/**
 * 获取用户个人信息
 */
export const getUserBaseInfo = (data) => fetch('/mvc/appSelf/personStanderInfo',data, 'POST','ajax',false);
/**
 * 工资条查询
 */
export const getSalary = (data) => fetch('/mvc/appSelf/payslip', data, 'POST','ajax',false,'','clock');
/**
 * 社保、公积金、年金查询
 */
export const getSiPayment = (data) => fetch('/mvc/appSelf/siFunAnnuity', data, 'POST','ajax',false,'','clock');
/**
 * 判断菜单显示
 */
export const getMenu = (data) => fetch('/mvc/appSelf/checkManager', data, 'POST','ajax',false);
/**
 * 获取荣誉列表数据
 */
export const getHonorList = (data) => fetch('/mvc/appSelf/selfHonor', data, 'POST','ajax',false,'','clock');

/* 中铁建接口结束 */



/**
 * 获取用户信息
 */
export const getUser = (data) => fetch('/mvc/empselfhelp/personSelfInfo', data, 'POST','ajax',false);

/**
 * 获取用户个人信息
 */
// export const getUserBaseInfo = (data) => fetch('/mvc/person/personStanderInfo',data, 'POST','ajax',false,'','clock');
// export const getUserBaseInfo = (data) => fetch('/mvc/person/personStanderInfo', data, 'POST','ajax',false);



/**
 * 奖金查询
 */
export const getBonus = (data) => fetch('/mvc/selfPerformance/selfPerformanceBonus', data, 'POST','ajax',false);


/**
 * 绩效结果查询
 */
export const getCzbevaResult = (data) => fetch('/mvc/selfPerformance/getSelfCzbevaResult', data, 'POST','ajax',false);
/**
 * 考勤信息查询
 */
export const getAttendanceResult = (data) => fetch('/mvc/attendancemonthreport/getDataByMonth', data, 'POST','ajax',false);
/*
* 查询用户信息
* */
export const getUserInfo = (data) => fetch('/mvc/empselfhelp/userInfo', data, 'POST','ajax',false);

/*
* 经理自助 获取可查看机构列表
* */
export const managerOrgs = (data) => fetch('/mvc/appSelf/managerOrgs', data, 'POST','ajax',false);

/*
* 经理自助根据ORG ID 获取机构下人员列表
* */
export const managerPerson = (data) => fetch('/mvc/appSelf/managerPerson', data, 'POST','ajax',false);


/*
* 经理自助获取员工考勤信息
* */
export const getPersonAtndData = (data) => fetch('/mvc/appSelf/getPersonAtndData', data, 'POST','ajax',false);

/*
* 查询基本信息
* */
export const getBasicInfo = (data) => fetch('/mvc/person/data', data, 'POST','ajax',false);

/*保存*/
export const saveCertificate = (pUrl,data) => fetch(pUrl, data, 'POST','ajax',false,'','clock');

/*查看申请*/
export const lookCertificate = (pUrl,data) => fetch(pUrl, data, 'GET','ajax',false);
/*我的申请*/
export const myApplay = (dates) => fetch('/mvc/appSelf/applyDatas',dates, 'POST', 'ajax');

/*我的消息*/
export const queryMessageList = (dates) => fetch('/mvc/sysMessage/datas',dates, 'POST', 'ajax',false);
/*查看详细消息*/
export const lookMessageDetail = (dates) => fetch('/mvc/rem/data',dates, 'GET', 'ajax',false);
/*已读消息*/
export const messageRead = (dates) => fetch('/mvc/rem/remRead',dates, 'POST', 'ajax',false);

/*公司财务指标*/
export const getFinancial = (dates) => fetch('/mvc/statistical/financialTargetStatistical',dates, 'POST', 'ajax',false);
/*公司人工成本*/
export const getAllDeptYearCost = (dates) => fetch('/mvc/selfWageController/getAllDeptYearCost',dates, 'POST', 'ajax',false);
/*工资总额统计*/
export const getAllDeptMonthWageTotal = (dates) => fetch('/mvc/selfWageController/getAllDeptYearWageTotal',dates, 'POST', 'ajax',false);
/*穿透列表*/
export const clickLists = (reqUrl,dates) => fetch(reqUrl,dates, 'POST','ajax',false,'','clock');
/*年龄*/
export const getPersonAge = (useId,dates) => fetch('/mvc/statistical/personAgeStatistical',dates, 'POST','ajax',false,'','clock');
/*工龄*/
export const getWorkAgeAge = (useId,dates) => fetch('/mvc/statistical/personWorkAgeStatistical',dates, 'POST','ajax',false,'','clock');
/*司龄*/
export const getCompanyAgeAge = (useId,dates) => fetch('/mvc/statistical/personCompanyAgeStatistical',dates, 'POST','ajax',false,'','clock');
/*学历*/
export const getPersonEducation = (useId,dates) => fetch('/mvc/statistical/personEducationStatistical',dates, 'POST','ajax',false,'','clock');
/*员工类别*/
export const getPersonType= (useId,dates) => fetch('/mvc/statistical/personTypeStatistical',dates, 'POST','ajax',false,'','clock');
/*政治面貌*/
export const getpersonParty= (useId,dates) => fetch('/mvc/statistical/personPartyFigureStatistical',dates, 'POST','ajax',false,'','clock');
/*职级*/
export const getPersonTechnical= (useId,dates) => fetch('/mvc/statistical/personTechnicalTitleGradeStatistical',dates, 'POST','ajax',false,'','clock');
/*职务层级*/

export const getPersonJobLevel= (useId,dates) => fetch('/mvc/statistical/personJobLevelStatistical',dates, 'POST','ajax',false,'','clock');
/*性别*/
export const getPersonSex= (useId,dates) => fetch('/mvc/statistical/personSexStatistical',dates, 'POST','ajax',false,'','clock');
/*入离职*/
export const getQueryPerson= (useId,dates) => fetch('/mvc/statistical/queryPersonChanges',dates, 'POST','ajax',false,'','clock');

/*已读消息*/
export const getDeptInfo = (dates) => fetch('/mvc/empselfhelp/deptInfo',dates, 'POST', 'ajax',false);
/*销售收入*/
export const getdeptMainBusiness = (useId,dates) => fetch('/mvc/statistical/deptMainBusinessEarningStatistical',dates, 'POST','ajax',false,'','clock');

/*利润总额*/
export const getdeptTotalProfits = (useId,dates) => fetch('/mvc/statistical/deptTotalProfitsStatistical',dates, 'POST','ajax',false,'','clock');
/*部门人工成本*/
export const getDeptYearCost = (dates) => fetch('/mvc/selfWageController/getDeptYearCost',dates, 'POST', 'ajax',false);
/*工资总额统计（按月累计）*/
export const getDeptYearWage = (dates) => fetch('/mvc/selfWageController/getDeptYearWageTotal',dates, 'POST', 'ajax',false);
/*获取我的待办列表*/
export const taskDatas = (data) => fetch('/mvc/appSelf/queryTask' ,data, 'POST', 'ajax');
/*根据taskid查询信息 GET*/
export const getDataByTaskId = (url,dates) => fetch(url,dates, 'GET', 'ajax',false);
/*根据taskid查询信息 POST*/
export const getDataByTaskId1 = (url,dates) => fetch(url,dates,'POST','ajax',false,'','clock');

/*账套数据请求*/
export const getWageAccount = (dates) => fetch('/mvc/wageaccount/databyunitid',dates, 'GET', 'ajax',false);
/*更新待办状态*/
export const updateCloseSysTask = (data) => fetch('/mvc/systask/updateCloseSysTask' ,data, 'POST', 'ajax',false);
/*查询合同信息*/
export const getContract = (data) => fetch('/mvc/personcontract/data' ,data, 'GET', 'ajax',false);
/*更新待办状态*/
export const getRetireData = (data) => fetch('/mvc/org/getRetireData' ,data, 'POST', 'ajax',false);
/*目标管理责任领导反馈数据查询*/
export const getQuerySelf = (dates) => fetch('/mvc/annualleaderconfirm/querySelfConfirm',dates, 'GET', 'ajax',false);
/*签订机构*/
export const getEmployeeOrg= (dates) => fetch('/mvc/personcontract/employeeOrgTree',dates, 'GET', 'ajax',false);


/*选择考核记录*/
export const selectPersonData= (dates) => fetch('/mvc/person/queryAssment',dates, 'POST', 'ajax',false);

/*绩效考评计划接口*/
export const getQueryPlan= (dates) => fetch('/api/appCzbeva/queryPlanExecuteList',dates, 'POST', 'ajax',false);
/*绩效考评历史计划接口*/
export const getHisQueryPlan= (dates) => fetch('/api/appCzbeva/queryHisPlanExecuteList',dates, 'POST', 'ajax',false);
/*绩效考评方式接口*/
export const getEvaType= (dates) => fetch('/api/appCzbeva/queryEvaTypeList',dates, 'POST', 'ajax',false);

/*绩效查看题目及需要考评的人员*/
export const getPlanTable= (dates) => fetch('/api/appCzbeva/queryPlanTableItemList',dates, 'POST', 'ajax',false);

/*提交绩效测评打分*/
export const submitGrade= (dates) => fetch('/api/appCzbeva/submitInfo',dates, 'POST','ajax',false,'','clock');
// export const submitGrade= (useId,dates) => fetch('/api/appCzbeva/submitInfo',dates, 'POST', 'ajax',false);

/*胜任力考评计划接口*/
export const getQuerySrlPlan= (dates) => fetch('/api/appCzbevaSrl/queryPlanExecuteList',dates, 'POST', 'ajax',false);
/*胜任力历史考评计划接口*/
export const getHisQuerySrlPlan= (dates) => fetch('/api/appCzbevaSrl/queryHisPlanExecuteList',dates, 'POST', 'ajax',false);
/*胜任力考评方式接口*/
export const getSrlEvaType= (dates) => fetch('/api/appCzbevaSrl/queryEvaTypeList',dates, 'POST', 'ajax',false);
/*胜任力查看题目及需要考评的人员*/
export const getSrlPlanTable= (dates) => fetch('/api/appCzbevaSrl/queryPlanTableItemList',dates, 'POST', 'ajax',false);
/*胜任力绩效测评打分*/
export const submitSrlGrade= (dates) => fetch('/api/appCzbevaSrl/submitInfo',dates, 'POST','ajax',false,'','clock');

/*我的提醒*/
export const myRemaind= (dates) => fetch('/mvc/appSelf/remDatas',dates, 'POST','ajax',false,'','clock');
/*我的提醒详细*/
export const myRemaindDetail= (dates) => fetch('/mvc/appSelf/queryRemPerson',dates, 'POST','ajax',false,'','clock');
/*目标管理*/
export const myTarget= (dates) => fetch('/mvc/annualworkcontent/apiDatas',dates, 'POST','ajax',false,'','clock');
/*员工申请户籍卡/户籍首页申请校验*/
export const householdVerification = (dates) => fetch('/mvc/selfmatterhouseholdregistercard/checkExist',dates, 'POST','ajax',false);
/*首页角标请求*/
export const indexCount = (url,dates) => fetch(url,dates, 'POST','ajax',false);



/*签订机构*/
export const getDict= (url,dates) => fetch(url,dates, 'GET', 'ajax',false);



/**
 * 获取绩效信息
 */

export const getPerformance = (data) => fetch('/queryPerformanceVo', data, 'POST','ajax',false,'','clock');

/**
 * 通讯录树数据
 */

export const getOrgTree = (data) => fetch('/getOrgTree', data, 'POST');

/*获取通讯录人员*/
export const queryAppPerson = (data) => fetch('/queryAppPersonVoByTreeId', data, 'POST','ajax',false,'','clock');

/*翻译代码项*/
export const dictNum = (dictId,data) => fetch(interfaceUrl+'/eHR/api/syscode/codeItemName?code_item_id='+dictId, data, 'POST','ajax',true,'','clock');
/**
 * 剩余年假天数
 */
export const annualLeave = (data) => fetch('/queryAnnualRemainDaysByPersonId',data, 'POST','ajax',false,'','clock');

/*获取请假类型*/
export const annualTypes = (data) => fetch('/getVacnLeaves',data, 'POST','ajax',false,'','clock');

/**
 * 上传文件
 */
export const uploadFile = (formData) => fetch(interfaceUrl+'/insight/api/file/att/uploadFile',formData,'POST','ajax',true,'file');

/*保存请假信息*/
export const saveLeave = (savaLeaveDatas) => fetch('/saveActAtndLeave',{"actAtndLeave":savaLeaveDatas }, 'POST','ajax',false,'','clock');

/*打卡*/

export const saveClockRecord = (punchData) => fetch('/saveClockRecord',punchData , 'POST','ajax',false,'','clock');

/*保存之前的判断*/
export const canSave = (data) => fetch('/checkStartProcessInstanceByCustom',data , 'POST','ajax');

/*保存出差信息*/

export const saveActAtndBusiness = (actAtndBusiness) => fetch('/saveActAtndBusiness',{"actAtndBusiness":actAtndBusiness }, 'POST','ajax',false,'','clock');

/*保存外出信息*/
export const saveActAtndGoOut = (data) => fetch('/saveActAtndGoOut',{"actAtndGoOut":data }, 'POST','ajax',false,'','clock');

/*保存未打卡信息*/
export const saveActForgetClock = (saveData) => fetch('/saveActAtndSupplementCard',{"actAtndSupplementCard":saveData }, 'POST','ajax',false,'','clock');

/*获取打卡类型*/
export const getWorkTimeType = (data) => fetch('/getWorkTimeType',data, 'POST','ajax',false,'','clock');

/*填表前调用发起流程请求*/
export const startProcess = (processData) => fetch('/startProcess' ,processData, 'POST','ajax');

/*流程发起接口*/
export const processInstance = (data) => fetch('/startProcessInstanceByCustom' ,data, 'POST', 'ajax');



/*进入待办前调用的接口*/
export const toHandlePage = (data) => fetch('/toHandlePage' ,data, 'POST', 'ajax');

/*获取待办业务数据*/
export const actdata = (actData) => fetch('/actdata ' ,actData, 'POST', 'ajax');

/*获取历史审批数据*/
export const hisTaskList  = (actData) => fetch('/hisTaskList' ,actData, 'POST', 'ajax');

/*获取交通工具类型*/
export const vehicle = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3220',data,'POST','ajax',true,'','clock');

/*获取个人信息接口*/
export const selfPersonInfo  = (actData) => fetch('/selectAppPersonInfo' ,actData, 'POST', 'ajax');

/*获取出差天数*/
export const evevtionDay  = (actData) => fetch('/getOverTimeAmount' ,actData, 'POST','ajax',false,'','clock');

/*获取补打卡时间*/
export const getWorkTime  = (data) => fetch('/getWorkTime' ,data, 'POST','ajax',false,'','clock');

/*再次提交驳回数据*/
export const submitFormByCustom  = (data) => fetch('/submitFormByCustom' ,data, 'POST', 'ajax');

/*审批接口*/
export const handleTask  = (actData) => fetch('/handleTask' ,actData, 'POST', 'ajax');

/*7)签收并审批*/

export const handleAndClaim  = (actData) => fetch('/handleAndClaimTask' ,actData, 'POST', 'ajax');

/*获取考勤信息*/
export const selfAttendanceTypeNew = (workData) => fetch('/selfAttendanceTypeNew',workData, 'POST','ajax',false,'','clock');

/*签到签退时间获取*/
export const selfAttendance = (clickdata) => fetch('/selfAttendanceDataNew',clickdata, 'POST','ajax',false,'','clock');

/*系统时间获取*/
export const sysTime = (data) => fetch('/getSysDate',data, 'POST','ajax',false,'','clock');

/*附件下载以及预览*/
//export const downloadFile = (data) => fetch('http://192.168.43.192:8082/insight/api/appInterface/downloadFile2',data, 'POST','fetch',true);
export const downloadFile = (data) => fetch('/downloadFile2',data ,'POST','ajax',false,'','clock');

/*获取文件类型*/
export const downloadFileType = (data) => fetch('/downloadFile3',data ,'POST','ajax',false,'','clock');

/*通讯录模糊查询*/
export const queryByData = (data) => fetch('/queryByData',data ,'POST','ajax',false,'','clock');

/*头像上传*/
export const uploadAvatar = (data) => fetch('/uploadFile',data ,'POST','ajax',false,'','clock');

/*头像上传*/
export const getSignInAndOut = (data) => fetch('/getSignInAndOut',data ,'POST','ajax',false,'','clock');

/*密码修改*/
export const updatePassword = (data) => fetch('/update',data ,'POST','ajax');

/*OA账户查询*/
export const queryOa = (data) => fetch('/queryOaAccount',data ,'POST','ajax');

/*OA账户设置*/
export const updateOa = (data) => fetch('/updateOaAccount',data ,'POST','ajax');

/*获取加班类型*/
export const overTimeType = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3223',data,'POST','ajax',true,'','clock');

/*获取补偿类型*/
export const makeUpType = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3224',data,'POST','ajax',true,'','clock');

/*保存加班信息*/
export const saveOvertime = (savaOverDatas) => fetch('/saveActAtndOvertime',{"actAtndOvertime":savaOverDatas }, 'POST','ajax',false,'','clock');

/*获取调休类型*/
export const breakOffType = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3225',data,'POST','ajax',true,'','clock');

/* 剩余调休天数*/
export const breakOffRemain = (data) => fetch('/getBreakOffRemainAmount',data, 'POST','ajax',false,'','clock');

/*保存调休信息*/
export const saveBreakOff = (savabreakDatas) => fetch('/saveActAtndBreakOff',{"actAtndBreakOff":savabreakDatas }, 'POST','ajax',false,'','clock');

/*调班人员查询*/
export const searchPerson = (data) => fetch('/queryPersonListByOrgId',data, 'POST','ajax',false,'','clock');

/*调班信息查询*/
export const getWorkClassInfo = (data) => fetch('/getWorkClassInfo',data, 'POST','ajax',false,'','clock');

/*保存调班信息*/
export const saveClassChange = (savaChangeDatas) => fetch('/saveActAtndClassChange',{"actAtndClassChange":savaChangeDatas }, 'POST','ajax',false,'','clock');

/*节日提醒*/
export const dataOfTime = (dates) => fetch('/dataOfTime',dates, 'POST','ajax',false,'','clock');






/*获取职级类型*/
export const ofRank = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3199',data,'POST','ajax',true,'','clock');

/*获取离职类型*/
export const offWork = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3209',data,'POST','ajax',true,'','clock');

/*获取离职原因*/
export const leaveReason = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3210',data,'POST','ajax',true,'','clock');

/*获取合同期限类型*/
export const contractPre = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3096',data,'POST','ajax',true,'','clock');

/*获取合同期限*/
export const contractQi = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3090',data,'POST','ajax',true,'','clock');

/*获取调整类型*/
export const adjustType = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3228',data,'POST','ajax',true,'','clock');

/*获取机构属性*/
export const adjustorgType = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/3049',data,'POST','ajax',true,'','clock');

/*获取性别*/
export const sexType = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/0100',data,'POST','ajax',true,'','clock');

/*获取城市*/
export const cityType = (data) => fetch(interfaceUrl+'/insight/api/appCommonSelf/cache/0105',data,'POST','ajax',true,'','clock');

/*获取岗位*/
export const postType = (data) => fetch('/queryByPostId',data, 'POST', 'ajax',false,'','clock');

/*获取机构数据*/
export const orgData = (data) => fetch('/queryByOrgId',data, 'POST', 'ajax',false,'','clock');

/*薪资口令接口*/
export const  command = (data) => fetch(interfaceUrl+'/insight/api/appSelf/verifyCode',data, 'POST','ajax',true);

/*薪资口令接口*/
export const  salaryDetail = (data) => fetch(interfaceUrl+'/insight/api/appSelf/queryWageByMonthApp',data, 'POST','ajax',true);

/**
 * 获取首页默认地址
 */

export const cityGuess = () => fetch('/v1/cities', {
	type: 'guess'
});


/**
 * 获取首页热门城市
 */

export const hotcity = () => fetch('/v1/cities', {
	type: 'hot'
});


/**
 * 获取首页所有城市
 */

export const groupcity = () => fetch('/v1/cities', {
	type: 'group'
});


/**
 * 获取当前所在城市
 */

export const currentcity = number => fetch('/v1/cities/' + number);


/**
 * 获取搜索地址
 */

export const searchplace = (cityid, value) => fetch('/v1/pois', {
	type: 'search',
	city_id: cityid,
	keyword: value
});


/**
 * 获取msite页面地址信息
 */

export const msiteAddress = geohash => fetch('/v2/pois/' + geohash);


/**
 * 获取msite页面食品分类列表
 */

export const msiteFoodTypes = geohash => fetch('/v2/index_entry', {
	geohash,
	group_type: '1',
	'flags[]': 'F'
});


/**
 * 获取msite商铺列表
 */

export const shopList = (latitude, longitude, offset, restaurant_category_id = '', restaurant_category_ids = '', order_by = '', delivery_mode = '', support_ids = []) => {
	let supportStr = '';
	support_ids.forEach(item => {
		if (item.status) {
			supportStr += '&support_ids[]=' + item.id;
		}
	});
	let data = {
		latitude,
		longitude,
		offset,
		limit: '20',
		'extras[]': 'activities',
		keyword: '',
		restaurant_category_id,
		'restaurant_category_ids[]': restaurant_category_ids,
		order_by,
		'delivery_mode[]': delivery_mode + supportStr
	};
	return fetch('/shopping/restaurants', data);
};


/**
 * 获取search页面搜索结果
 */

export const searchRestaurant = (geohash, keyword) => fetch('/v4/restaurants', {
	'extras[]': 'restaurant_activity',
	geohash,
	keyword,
	type: 'search'
});


/**
 * 获取food页面的 category 种类列表
 */

export const foodCategory = (latitude, longitude) => fetch('/shopping/v2/restaurant/category', {
	latitude,
	longitude
});


/**
 * 获取food页面的配送方式
 */

export const foodDelivery = (latitude, longitude) => fetch('/shopping/v1/restaurants/delivery_modes', {
	latitude,
	longitude,
	kw: ''
});


/**
 * 获取food页面的商家属性活动列表
 */

export const foodActivity = (latitude, longitude) => fetch('/shopping/v1/restaurants/activity_attributes', {
	latitude,
	longitude,
	kw: ''
});


/**
 * 获取shop页面商铺详情
 */

export const shopDetails = (shopid, latitude, longitude) => fetch('/shopping/restaurant/' + shopid, {
	latitude,
	longitude: longitude + '&extras[]=activities&extras[]=album&extras[]=license&extras[]=identification&extras[]=statistics'
});



/**
 * 获取shop页面菜单列表
 */

export const foodMenu = restaurant_id => fetch('/shopping/v2/menu', {
	restaurant_id
});


/**
 * 获取商铺评价列表
 */

export const getRatingList = (shopid, offset, tag_name = '') => fetch('/ugc/v2/restaurants/' + shopid + '/ratings', {
	has_content: true,
	offset,
	limit: 10,
	tag_name
});


/**
 * 获取商铺评价分数
 */

export const ratingScores = shopid => fetch('/ugc/v2/restaurants/' + shopid + '/ratings/scores');


/**
 * 获取商铺评价分类
 */

export const ratingTags = shopid => fetch('/ugc/v2/restaurants/' + shopid + '/ratings/tags');


/**
 * 获取短信验证码
 */

export const mobileCode = phone => fetch('/v4/mobile/verify_code/send', {
	mobile: phone,
	scene: 'login',
	type: 'sms'
}, 'POST');


/**
 * 获取图片验证码
 */

export const getcaptchas = () => fetch('/v1/captchas', {},'POST');


/**
 * 检测帐号是否存在
 */

export const checkExsis = (checkNumber, type) => fetch('/v1/users/exists', {
	[type]: checkNumber,
	type
});


/**
 * 发送帐号
 */

export const sendMobile = (sendData, captcha_code, type, password) => fetch('/v1/mobile/verify_code/send', {
	action: "send",
	captcha_code,
	[type]: sendData,
	type: "sms",
	way: type,
	password,
}, 'POST');


/**
 * 确认订单
 */

export const checkout = (geohash, entities, shopid) => fetch('/v1/carts/checkout', {
	come_from: "web",
	geohash,
	entities,
	restaurant_id: shopid,
}, 'POST');


/**
 * 获取快速备注列表
 */

export const getRemark = (id, sig) => fetch('/v1/carts/' + id + '/remarks', {
	sig
});


/**
 * 获取地址列表
 */

export const getAddress = (id, sig) => fetch('/v1/carts/' + id + '/addresses', {
	sig
});


/**
 * 搜索地址
 */

export const searchNearby = keyword => fetch('/v1/pois', {
	type: 'nearby',
	keyword
});


/**
 * 添加地址
 */

export const postAddAddress = (userId, address, address_detail, geohash, name, phone, phone_bk, poi_type, sex, tag, tag_type) => fetch('/v1/users/' + userId + '/addresses', {
	address,
	address_detail,
	geohash,
	name,
	phone,
	phone_bk,
	poi_type,
	sex,
	tag,
	tag_type,
}, 'POST');


/**
 * 下订单
 */

export const placeOrders = (user_id, cart_id, address_id, description, entities, geohash, sig) => fetch('/v1/users/' + user_id + '/carts/' + cart_id + '/orders', {
	address_id,
	come_from: "mobile_web",
	deliver_time: "",
	description,
	entities,
	geohash,
	paymethod_id: 1,
	sig,
}, 'POST');


/**
 * 重新发送订单验证码
 */

export const rePostVerify = (cart_id, sig, type) => fetch('/v1/carts/' + cart_id + '/verify_code', {
	sig,
	type,
}, 'POST');



/**
 * 下订单
 */

export const validateOrders = ({
	user_id,
	cart_id,
	address_id,
	description,
	entities,
	geohash,
	sig,
	validation_code,
	validation_token
}) => fetch('/v1/users/' + user_id + '/carts/' + cart_id + '/orders', {
	address_id,
	come_from: "mobile_web",
	deliver_time: "",
	description,
	entities,
	geohash,
	paymethod_id: 1,
	sig,
	validation_code,
	validation_token,
}, 'POST');


/**
 * 重新发送订单验证码
 */

export const payRequest = (merchantOrderNo, userId) => fetch('/payapi/payment/queryOrder', {
	merchantId: 5,
	merchantOrderNo,
	source: 'MOBILE_WAP',
	userId,
	version: '1.0.0',
});



/**
 * 获取服务中心信息
 */

export const getService = () => fetch('/v3/profile/explain');



/**
*兑换会员卡
*/

export const vipCart = (id, number, password) => fetch('/member/v1/users/' + id + '/delivery_card/physical_card/bind',{
	number,
	password
}, 'POST')



/**
 * 获取红包
*/

export const getHongbaoNum = id => fetch('/promotion/v2/users/' + id + '/hongbaos?limit=20&offset=0');



/**
 * 获取过期红包
*/


export const getExpired = id => fetch('/promotion/v2/users/' + id + '/expired_hongbaos?limit=20&offset=0');


/**
 * 兑换红包
*/

export const exChangeHongbao = (id, exchange_code, captcha_code) => fetch('/v1/users/' + id + '/hongbao/exchange',{
	exchange_code,
	captcha_code,
}, 'POST');





/**
 * 手机号登录
 */

var sendLogin = (code, mobile, validate_token) => fetch('/v1/login/app_mobile', {
	code,
	mobile,
	validate_token
}, 'POST');


/**
 * 获取订单列表
 */

export const getOrderList = (user_id, offset) => fetch('/bos/v2/users/' + user_id + '/orders', {
	limit: 10,
	offset,
});


/**
 * 获取订单详情
 */

export const getOrderDetail = (user_id, orderid) => fetch('/bos/v1/users/' + user_id + '/orders/' + orderid + '/snapshot');


/**
*个人中心里编辑地址
*/

export const getAddressList = (user_id) => fetch('/v1/users/'+user_id+'/addresses')

/**
*个人中心里搜索地址
*/

export const getSearchAddress = (keyword) => fetch('v1/pois',{
	keyword:keyword,
	type:'nearby'
})

/**
* 删除地址
*/

export const deleteAddress = (userid, addressid) => fetch( '/v1/users/' + userid + '/addresses/' + addressid, {}, 'DELETE')



/**
 * 账号密码登录
 */
export const accountLogin = (username, password, captcha_code) => fetch('/v2/login', {username, password, captcha_code}, 'POST');


/**
 * 退出登录
 */
export const signout = () => fetch('/v2/signout');


/**
 * 改密码
 */
export const changePassword = (username, oldpassWord, newpassword, confirmpassword, captcha_code) => fetch('/v2/changepassword', {username, oldpassWord, newpassword, confirmpassword, captcha_code}, 'POST');
